package com.action;

import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;

import com.manager.KeywordManager;
import com.model.Keyword;
import com.model.ModuleConstant;
import com.opensymphony.xwork2.ActionSupport;


@ParentPackage("json-default")
@Results({ @Result(name = "jsonResult", type = "json") })
@Namespace("/user")
public class AreplyAction extends ActionSupport{
	
	@Autowired
	private KeywordManager keywordManager;
	
	private Keyword keyword;
	
	public Keyword getKeyword() {
		return keyword;
	}

	public void setKeyword(Keyword keyword) {
		this.keyword = keyword;
	}

	public String add(){
		try {
			keyword = (Keyword)keywordManager.find("from Keyword k where k.type=?", new Object[]{ModuleConstant.SUBEVENT});
		} catch (Exception e) {
			
		}
		return "add";
	}
	
	public String addTo(){
//		Keyword key = null;
//		try {
//			key = (Keyword)keywordManager.find("from Keyword k where k.type=?", new Object[]{ModuleConstant.SUBEVENT});
//		} catch (Exception e) {
//		}
//		if(key != null){
//			
//		}
		keywordManager.saveOrUpdate(keyword);
		return add();
	}
}
